
#ifndef _ka_io_buffer_h
#define _ka_io_buffer_h

#include "ka-system/types.h"

namespace io {
    class Buffer {
    public:
        static const uint32_t ORDER_BIG_ENDIAN = UINT32_C(0);
        static const uint32_t ORDER_LITTLE_ENDIAN = UINT32_C(1);
        Buffer(size_t size);
        ~Buffer();
        void setOrder(uint32_t order);
        uint32_t getOrder() const;
        size_t getSize() const;
        void putInt(size_t offset, int32_t v);
        void putUInt(size_t offset, uint32_t v);
        void putLong(size_t offset, int64_t v);
        void putULong(size_t offset, uint64_t v);
        void putShort(size_t offset, int16_t v);
        void putUShort(size_t offset, uint16_t v);
        void putByte(size_t offset, int8_t v);
        void putUByte(size_t offset, uint8_t v);
        void putBytes(size_t offset, const void *source, size_t byteCount);
        int32_t getInt(size_t offset);
        uint32_t getUInt(size_t offset);
        int64_t getLong(size_t offset);
        uint64_t getULong(size_t offset);
        int16_t getShort(size_t offset);
        uint16_t getUShort(size_t offset);
        int8_t getByte(size_t offset);
        uint8_t getUByte(size_t offset);
        void getBytes(size_t offset, void *dest, size_t byteCount);
        void resize(size_t size);
        uint8_t *getDataPtr();
        const uint8_t *getDataPtr() const;
    public:
        static uint32_t getNativeOrder();
    private:
        uint8_t *_data;
        size_t _size;
        bool _swap;
    };
}

#endif